package com.example.teesystem.entityDto;

import com.example.teesystem.common.cache.UserCache;
import com.example.teesystem.common.utils.TimeUtil;
import com.example.teesystem.entity.ExamEvaluation;
import com.example.teesystem.entity.ExamPaper;
import com.example.teesystem.entity.User;
import lombok.Data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : NieYaShi
 * @version : v1.0
 * @createTime : 2022/4/21 16:19
 */
@Data
public class MarkedPaperMessage {
    private Integer studentId;
    private String studentName;
    private Integer studentScore;
    private Integer courseId;
    private Integer paperId;
    private String paperName;
    private String examTime;
    private Integer teacherId;
    private String teacherName;
    private Integer paperScore;
    private String message;
    private Map<String, List<MarkedIssueMessage>> listMap = new HashMap<>();

    public MarkedPaperMessage(Integer studentId, ExamPaper examPaper, ExamEvaluation examEvaluation){
        this.studentId = studentId;
        this.studentScore = examEvaluation.getScore();
        this.courseId = examPaper.getCourseId();
        this.paperId = examPaper.getId();
        this.paperName = examPaper.getName();
        this.examTime = TimeUtil.dateTimeToString(examPaper.getStartTime());
        this.teacherId = examPaper.getTeacherId();
        User def = new User();
        def.setMyName("用户名未找到");
        this.studentName = UserCache.userMap.getOrDefault(studentId, def).getUsername();
        this.teacherName = UserCache.userMap.getOrDefault(examPaper.getTeacherId(), def).getMyName();
        this.paperScore = examPaper.getScore();
        this.message = examEvaluation.getMessage();
    }
}
